home *** CD-ROM | disk | FTP | other *** search
- IFND LIBRARIES_PATCH_I
- LIBRARIES_PATCH_I SET 1
- **
- ** Filename: libraries/patch.i
- ** Release: 4.0
- ** Date: 31.01.96
- **
- ** (C) Copyright 1993-96 Stefan Fuchs
- ** All rights reserved
- **
- ** definition of patch.library public structures, returncodes and macros
-
-
- IFND EXEC_TYPES_I
- include "exec/types.i"
- ENDC
-
- IFND EXEC_LISTS_I
- include "exec/lists.i"
- ENDC
-
- IFND EXEC_LIBRARIES_I
- include "exec/libraries.i"
- ENDC
-
- IFND EXEC_SEMAPHORES_I
- include "exec/semaphores.i"
- ENDC
-
- ;-------------------------------------------------------------------------
- ;Structure required to install new patches via patch.library/InstallPatch()
-
- STRUCTURE NewPatch,0 ;this structure is OBSOLETE from V2 on
- APTR NPAT_NewCode ;pointer to the patch code to be installed
- ULONG NPAT_NewCodeSize ;optional length of NPAT_NewCode in bytes
- APTR NPAT_LibraryName ;pointer to the LibraryName
- UWORD NPAT_LibVersion ;version of Library to open
- WORD NPAT_LVO ;LVO of function to patch
- WORD NPAT_Priority ;Priority (-127...+126) of the patch
- UWORD NPAT_Flags ;currently none defined (keep zero)
- APTR NPAT_PatchName ;optional pointer to an IDString
- LONG NPAT_Result2 ;optional pointer to longword for Result2
-
- LABEL NPAT_SIZEOF
-
- ;-------------------------------------------------------------------------
- ;ErrorCodes:
- PATERR_Ok equ 0 ;Everything Ok
- PATERR_PatchInUse equ 1 ;Patch Usecount <> 0
- PATERR_InvalidHandle equ 2 ;Pointer to patch is not (no longer) valid
- PATERR_OutOfMem equ 3 ;Out of memory
- PATERR_OpenLib equ 4 ;Failed to open requested library
- PATERR_FuncNotStd equ 5 ;Function to patch is not in the standard format
- PATERR_PatchInstalled equ 6 ;Can't remove patch because another program has
- ;installed a non-patch.library patch later
- PATERR_InvalidTags equ 7 ;There was an error in the combination of the specified Tags
- PATERR_OpenDev equ 8 ;Failed to open requested device
- PATERR_NoTaskList equ 9 ;PATT_AddTask... or PATT_RemTask... was specified for a patch,
- ;which had no PATT_CreateTaskList set
- PATERR_TaskListExists equ 10 ;PATT_CreateTaskList was specified, but there already exists a TaskList
- PATERR_InvalidTaskList equ 11 ;PATT_CreateTaskList was specified with a wrong parameter
- PATERR_PatchUnnamed equ 12 ;PATT_PatchName with GetPatch was specified, for a patch without an IDString
- PATERR_NoSemaphore equ 13 ;Could not allocate semaphore
-
- ;-------------------------------------------------------------------------
- PATCHNAME MACRO
- dc.b "patch.library",0
- ENDM
-
- ;---------------------------------------------------------------
- ;--- FALLBACK - Call this macro instead of a 'rts' instruction
- ;--- in your patchcode, if you want to return to the original
- ;--- library code
- ;--- WARNING: The FALLBACK macro may be replaced by a better solution in V5,
- ;--- and may eventually no longer work in later versions. Please E-Mail me,
- ;--- if you use the FALLBACK macro.
- ;---------------------------------------------------------------
- FALLBACK MACRO
- move.l (sp),-(sp)
- clr.l 4(sp)
- rts
-
- ENDM
-
- ;---------------------------------------------------------------
- ;--- GETPATCHBASE - Call this macro, if you need to call patch.library
- ;--- functions within a patchcode
- ;--- - DO NOT USE OUTSIDE A PATCHCODE
- ;--- - DO NOT USE, IF YOU PATCH EXEC.LIBRARY/FINDNAME()
- ;--- Returns patchbase in a6
- ;---------------------------------------------------------------
- GETPATCHBASE MACRO
- movem.l d0/d1/a0/a1,-(sp)
- move.l 4.w,a6
- move.l LibList(a6),a0
- lea.l 2$(pc),a1
- jsr -276(a6) ;FindName
- move.l d0,a6
- movem.l (sp)+,d0/d1/a0/a1
- bra 1$
- 2$ dc.b "patch.library",0
- even
- 1$
- ENDM
-
-
- ;----------------------------------------------------------------------------
- ;----------------------------------------------------------------------------
- ;The following structures are not needed by normal patch.library applications
- ;----------------------------------------------------------------------------
- ;----------------------------------------------------------------------------
- STRUCTURE PatchBase,LIB_SIZE
- UBYTE PB_Flags ;no public flags defined
- UBYTE PB_reserved1
- ULONG PB_private1
-
- STRUCT PB_Semaphore,SS_SIZE ;Semaphore to protect MasterPatchList
- STRUCT PB_MasterPatchHeader,LH_SIZE ;Listheader structure for MasterPatch structures
-
- ;...
-
- ;-------------------------------------------------------------------------
- ; Before accessing this structure, make sure MPS_TYPE is PS_TYPE_MASTER
-
- STRUCTURE MasterPatch,0 ;This structure is READONLY
- APTR MPS_SUCC ;Pointer to next (successor)
- APTR MPS_PRED ;Pointer to previous (predecessor)
- UBYTE MPS_TYPE ;MUST be PS_TYPE_MASTER
- BYTE MPS_PRI ;Priority, for sorting
- APTR MPS_NAME ;may contain a pointer to the name of the patched library
- ;To compensate the loss of a valid librarybase
- ;MPS_NAME is now (V4) guranteed to contain a valid name
- ;this may however be a library, device or resource name
- UWORD MPS_Flags ;no public flags defined
- STRUCT MPS_PatchHeader,MLH_SIZE ;Listheader Structure for Patch structures
- APTR MPS_Private01 ;This pointer, up to V3 known as MPS_PatchedLibraryBase
- ;has been renamed, because with the introduction of the
- ;PatchSupervisor it may or may not contain a valid
- ;librarybase, it may even contain 0.
- UWORD MPS_PatchedLVO ;Library Vektor Offset in patched Library
-
- ;...
-
- ;--------------------------------------------------------------------------
- ; Before accessing this structure, make sure PS_TYPE is either PS_TYPE_USER or PS_TYPE_SYSTEM
- ; Make sure your program can handle lists, that do not contain any nodes of
- ; PS_TYPE_USER or PS_TYPE_SYSTEM
-
- STRUCTURE Patch,0 ;This structure is READONLY
- APTR PS_SUCC ;Pointer to next (successor)
- APTR PS_PRED ;Pointer to previous (predecessor)
- UBYTE PS_TYPE ;MUST be PS_TYPE_USER or PS_TYPE_SYSTEM
- BYTE PS_PRI ;Priority, for sorting
- APTR PS_NAME ;may contain a pointer to the name of the patch
- UWORD PS_Flags ;no public flags defined
-
- ;...
-
- ;-------------------------------------------------------------------------
- ;Public types for patch and masterpatch structures:
- PS_TYPE_MASTER = 1 ;node is MasterPatch structure
- PS_TYPE_USER = 2 ;node was installed by an Application using the library interface
- PS_TYPE_SYSTEM = 3 ;node was installed by the support program PatchSetFunc
-
-
- ENDC ;LIBRARIES_PATCH_I
-